/*
 * Images.java
 *
 *  created: 7.9.2011
 *  charset: UTF-8
 *  license: MIT (X11) (See LICENSE file for full license)
 */
package cz.mp.k3bg;

import cz.mp.k3bg.log.LoggerManager;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import javax.swing.ImageIcon;

/**
 * Třída {@code Images} umožňuje přístup k obrázkům v resources.
 *
 * @author Martin Pokorný
 * @version 0.1
 */
public class Images {

    private static final boolean DEBUG = false;
    private static final Logger logger =
            LoggerManager.getLogger(Images.class, DEBUG);   
    
    private static final String IMG_RESOURCE = "/resources/images/";
    
    /** */
    private Images() {        
    }

    /**
     * Seznam obrázků;
     * klíč je jméno souboru obrázku.
     */
    private static Map<String, ImageIcon> images = 
            new HashMap<String, ImageIcon>();

    public static final String SPLASH_SCREEN = "splash.gif";

    public static final String LOGO_16 = "logo_16.png";
    public static final String LOGO_32 = "logo_32.png";
    public static final String LOGO_48 = "logo_48.png";
    public static final String LOGO_128 = "logo_128.png";

    public static final String INFO_32 = "info_32.png";
    public static final String EBOOK_32 = "ebook_32.png";
    public static final String LISTS_32 = "lists_32.png";
    
    public static final String OK = "tick_green.png";
    public static final String CANCEL = "cross_gray.png";
    public static final String STOP = "playback_stop.png";

    public static final String FOLDER = "file_open.png";
    public static final String SAVE = "file_save_old.png";
    public static final String NEW = "file_new.png";

    public static final String PLUS = "plus.png";
    public static final String MINUS = "minus_orange.png";
    
    public static final String ARROW_UP = "arrow_up_blue.png";
    public static final String ARROW_DOWN = "arrow_down_blue.png";

    public static final String INFO = "info.png";
    public static final String HELP = "help.png";
    
    public static final String GEAR = "gear.png";    
    public static final String DETAIL = "detail.png";
    public static final String IMPORT = "import.png";
    
    public static final String GLOBE = "globe.png";    
    
    public static final String BLANK = "blank_icon.png";
    public static final String BULB = "bulb.png";
    public static final String ERROR = "notify_error_small.png";
    public static final String WARNING = "notify_warning_small.png";   
      
    /**
     * 
     * @param imgName  jméno obrázku např. 
     *      {@linkplain #OK}, {@linkplain #CANCEL}
     * @return 
     *      {@code null}, pokud není zadané jméno definováno, jinak ikonu.
     */
    public static ImageIcon getImage(String imgName) {
        if (!images.containsKey(imgName)) {
            URL imgURL = Images.class.getResource(IMG_RESOURCE + imgName);
            if (imgURL != null) {
                images.put(imgName, new ImageIcon(imgURL));
            }
            else {
                logger.warning("imgName " + imgName + "  NOT FOUND !");
            }
        }
        return images.get(imgName);
    }
}   // Images
